#include <iostream>

class Person
{
public:
    Person()
    {
        std::cout << "Person()" << std::endl;
    }
    Person(int age)
    {
        m_Age = age;
        std::cout << "Person(int age)" << std::endl;
    }
    Person(const Person &p)
    {
        m_Age = p.m_Age;
        std::cout << "Person(const Person &p)" << std::endl;
    }
    ~Person()
    {
        std::cout << "~Person()" << std::endl;
    }
    int m_Age;
};

// 1.使用一个已经存在的对象来创建新的对象
void test01()
{
    Person p1(20);
    Person p2(p1);
    std::cout << "p2.m_Age = " << p2.m_Age << std::endl;
}

// 2.值传递
void func01(Person p)
{

}

void test02()
{
    Person p;
    func01(p);
}

// 3.值方式返回局部对象
Person func3()
{
    Person p1;
    return p1;
}

void test03()
{
    Person p = func3();
}

int main()
{
    //test01();
    //test02();
    test03();
    return 0;
}